package com.javasm.crm.controller.marketingActivity;

import com.javasm.crm.common.http.AxiosResult;
import com.javasm.crm.domin.entity.marketingActivity.Promotion;
import com.javasm.crm.domin.entity.marketingActivity.clinetClaim.PromotionFindClaim;
import com.javasm.crm.service.marketingActivity.PromotionService;
import com.javasm.crm.utils.page.PageResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：llyp
 * @Version：1.0
 * @Date：2021/7/12-11:37
 * @Since:jdk1.8
 * @Description:TODO
 */
@RestController
@RequestMapping("/Promotion")
@Api(value = "promotionController" ,description = "促销活动管理明细")
public class PromotionController {

    @Autowired
    private PromotionService promotionService;


    /**
     * 分页条件查询
     * @param pfc
     * @return
     */
    @GetMapping("/findCondition")
    public AxiosResult<PageResult> find(PromotionFindClaim pfc){
        System.out.println("页面传过来的值====》"+pfc.getPromotionId());
        PageResult<Promotion> pageResult = promotionService.ConditionFindPage(pfc);

        return AxiosResult.success(pageResult);
    }

    /**
     * 添加
     * @param promotion
     * @return
     */
    @PostMapping("add")
    public AxiosResult addPromotion(@RequestBody Promotion promotion){
        System.out.println("添加的数据===》"+promotion);
        boolean save = promotionService.save(promotion);
        return AxiosResult.success(save);
    }

    /**
     * 修改
     * @param promotion
     * @return
     */
    @PostMapping("update")
    public AxiosResult updatePromotion(@RequestBody  Promotion promotion){

        boolean b = promotionService.updateById(promotion);
        return AxiosResult.success(b);
    }

    /**
     * 按id删除
     * @param id
     * @return
     */
    @GetMapping("delete")
    public AxiosResult  deletePromotion( Integer id){
        System.out.println("序号id"+id);
        boolean b = promotionService.removeById(id);
        return AxiosResult.success(b);
    }

    /**
     * id查询
     * @return
     */
    @GetMapping("findid")
    public  AxiosResult findid(Promotion promotion){
        Promotion byId = promotionService.getById(promotion);
        return AxiosResult.success(byId);
    }

    /**
     * 选择商品
     */
}
